import request from '@/utils/request'

// 获取列表
export const courseList = (params) => {
    return request.get('/course/list', { params })
}

/**
 * 关键字搜索
 * @param String keyword 
 * @returns void
 */
export function getListByKeyword(keyword) {
	return new Promise((resolve, reject) => {
        const params = { name: keyword }
		request.get('/course/list-by-keyword', { params }).then(res => {
			resolve(res.data)
		}).catch(error => {
			reject(error)
		})
	})
}

// 获取课程详情
export const courseInfo = (params) => {
    return request.get('/course/info', { params })
}

// 获取课程词汇列表
export const courseWordsList = (params) => {
    return request.get('/course-vocabulary/list', { params })
}


// 获取课程章节列表
export const courseChapterList = (params) => {
    return request.get('/course/chapter', { params })
}

// 获取课程词汇列表
export const courseWordItems = (params) => {
    return request.get('/course-vocabulary/all-by-letter', { params })
}

/**
 * 关键字搜索
 * @param String keyword 
 * @returns void
 */
export function getDictWordssBykeyword(keyword) {
	return new Promise((resolve, reject) => {
        const params = { word: keyword }
		request.get('/dict-words/list', { params }).then(res => {
			resolve(res.data)
		}).catch(error => {
			reject(error)
		})
	})
}